<template>
  <div class="c-flex-column c-aligni-center" v-if="payInfo">
    <div class="c-ww234 c-m-0auto c-pt120">
      <img class="c-w100 imgCloseBig c-ml-12" src="https://kposshzcdn.ckjr001.com/admin/material/9_material_admin/image/assets/i/wap/mall/payBonusIntegral.png">
    </div>
    <div class="c-mt40 c-flex-row c-aligni-center c-justify-center c-fc-xblack c-fs28 c-lh40">
      <template v-if="payInfo.useCoinPay == false"><span>订单成功支付</span><span class="c-fw-b" v-if="payInfo.price">{{'￥' | iosPriceFilter}}</span><span class="c-fw-b">{{payInfo.price}}</span></template>
      <template v-else>支付成功</template>
    </div>
    <div class="c-mt16 c-flex-row c-aligni-center c-justify-center c-fc-gray c-fs24 c-lh34 c-mb80"><span>恭喜您此次支付获得</span><span class="theme-fc">{{payInfo.givenPoints}}{{customPointName}}</span></div>
    <span class="theme-bg c-pv16 c-ph40 c-br36 c-fc-white c-m-0auto c-fs28" @click="getOrderDetail">查看订单</span>
  </div>
</template>

<script>
import { utilJs } from "@/utils/common.js";
export default {
  name: "PayGivenPoints",
  data() {
    return {
      customPointName: localStorage.getItem("customPointName"),
      payInfo: null //赠送积分和商品价格
    }
  },
  // 离开本页面的清空缓存
  beforeRouteLeave(to, from, next) {
    if (to.path != '/mall/shopSettlement/payGivenPoints') {
      sessionStorage.removeItem('payInfo');
    }
    next();
  },
  activated() {
    setDocumentTitle("支付成功");
    this.payInfo = JSON.parse(sessionStorage.getItem('payInfo')) ? JSON.parse(sessionStorage.getItem('payInfo')) : null;
  },
  methods: {
    getOrderDetail() {
      this.$routerGo(this, "replace", { path: '/mall/mallOrder/orderDetail', query: {goId: this.payInfo.goId} })
    },
    wechatShare: function () {
      let title = "首页";
      let shareImg = window.localStorage.getItem("shareLogo");
      let shareUrl = window.location.href.split("#")[0] + '&refereeId=' + localStorage.getItem("userId");
      let shareDesc = "点击查看详情";
      utilJs.wechatConfig(shareUrl, title, shareImg, shareDesc);
    },
    //手机端分享
    appShare: function () {
      let title = "首页";
      let shareImg = window.localStorage.getItem("shareLogo");
      let shareUrl = window.location.href.split("#")[0] + '&refereeId=' + localStorage.getItem("userId");
      let shareDesc = "点击查看详情";
      utilJs.appShareTrue(title, shareImg, shareUrl, shareDesc);
    },
  }
}
</script>

<style scoped>
.c-ww234 {
  width: 5.85rem;
}
.c-ml-12 {
  margin-left: -0.3rem;
}
</style>